{% extends 'my/layout.html.twig' %}

{% block title %}{{'my.teaching.testpaper.test_record'|trans}} - {{ parent() }}{% endblock %}
{% set side_nav = 'my-testpaper' %}

{% block main %}
  <div class="panel panel-default panel-col">
    <div class="panel-heading">{{'my.learning.testpaper'|trans}}</span></div>
    <div class="panel-body">
      <ul class="nav nav-pills mb15">
        <li class="{% if nav == 'testpaper' %}active{% endif %}"><a href="{{ path('my_testpaper_list') }}">{{'my.learning.testpaper.record'|trans}}</a></li>
        <li class="{% if nav == 'questionFavorite'%}active{% endif %}"><a href="{{ path('my_favorite_question_list') }}">{{'my.learning.testpaper.favorit_question'|trans}}</a></li>
      </ul>

      {% if answerRecords %}
        <table class="table table-striped table-hover">
          <tbody>
            {% for answerRecord in answerRecords %}
              {% set assessment = assessments[answerRecord.assessment_id]|default(null) %}
              {% set activity = activities[testpeaperActivities[answerRecord['answer_scene_id']]['id']]|default(null) %}
              {% set task = tasks[activity.id]|default(null) %}
              {% set course = courses[task.courseId]|default(null) %}
              {% set answerReport = answerReports[answerRecord['answer_report_id']]|default(null) %}
                <tr>
                  <td width="55%">
                    {{ task.title|default(assessment.name)|plain_text(60) }}
                    <div>
                      <small class="color-gray">
                        {{ 'come.from'|trans }}<a class="link-primary" href="{{ path('course_show',{id:course.id}) }}" target="_blank">《{{get_formated_course_title(course)}}》</a>
                      </small>
                      <small class="color-gray mhs">•</small>
                      <small class="color-gray" title="{{'my.teaching.testpaper.start_test_time'|trans}}">{{ answerRecord.begin_time|date('site.date_format'|trans) }}</small>
                    </div>
                  </td>

                  <td class="vertical-middle">
                    {% if answerRecord.status == 'reviewing' %}
                      <span class="color-warning">{{'my.teaching.testpaper.checking'|trans}}</span>
                    {% elseif answerRecord.status == 'finished' %}
                      <span class="color-gray">{{'my.teaching.testpaper.check_total_score'|trans({'%totalScore%': answerReport.score})|raw}}</span><br>
                      <small class="color-gray">
                        {{'my.teaching.testpaper.check_right_count'|trans({'%rightCount%': answerReport.right_question_count})|raw}}
                        {% if assessment %}/{{'my.teaching.testpaper.check_total_count'|trans({'%totalCount%': assessment.question_count})|raw}}{% endif %}
                      </small>
                    {% else %}
                      <span class="color-gray">{{'my.teaching.testpaper.unsubmit'|trans}}</span>
                    {% endif %}
                  </td>
                  <td class="vertical-middle">
                    {% if answerRecord.status in ['doing', 'paused'] %}
                      <a class="color-primary" href="{{ path('course_task_show',{courseId:course.id,id:task.id}) }}" >{{'my.teaching.testpaper.continue_do'|trans}}</a>
                    {% elseif answerRecord.status == 'finished' %}
                      {% if task %}
                        <a class="color-primary" href="{{ path('testpaper_result_show',{answerRecordId:answerRecord.id,action:'my'}) }}" class="btn btn-link btn-sm" target="_blank">{{'my.teaching.testpaper.watch_result'|trans}}</a>
                      {% endif %}
                    {% endif %}
                  </td>
                </tr>
            {% endfor %}

          </tbody>
        </table>
        {{ web_macro.paginator(paginator) }}
      {% else %}
        <div class="empty">{{'my.teaching.testpaper.not_participate_test'|trans}}</div>
      {% endif %}

    </div>
  </div>

{% endblock %}
